package edu.hnu.cloudflight.android.supply;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.DatePicker;
import android.widget.TextView;
import edu.hnu.cloudflight.android.util.DateUtil;

public class DateBtnOnclick implements OnClickListener {

	private TextView textView;
	private Context context;
	private static Calendar c =Calendar.getInstance();
	
	public DateBtnOnclick(TextView v, Context con) {
		this.textView = v;
		this.context = con;
	}

	@Override
	public void onClick(View v) {
		new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {

			@Override
			public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
				String date = DateUtil.getStringFromParams(year-1, monthOfYear+1, dayOfMonth);
				textView.setText(date);
			}
		}, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)).show();

	}

}
